package com.qiuzhiyi.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.li.widget.TopNavigationBar;
import com.qiuzhiyi.R;
import com.qiuzhiyi.base.QZYBaseActivity;
import com.qiuzhiyi.fragment.MsgLoginFragment;
import com.qiuzhiyi.fragment.PwdLoginFragment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;

/**
 * Author: Li
 * Date: 2017/11/14 0014
 * Description: 登录界面
 */

public class LoginActivity extends QZYBaseActivity {
    @BindView(R.id.top_navigation)
    TopNavigationBar mTopNavigation;
    @BindView(R.id.tab_layout)
    TabLayout mTabLayout;
    @BindView(R.id.pager)
    ViewPager mPager;

    private List<Fragment> mFragmentList;
    private List<String> mTitleList;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initSth() {
        super.initSth();
        mTopNavigation.setNavigationBarListener(this);
        mFragmentList = new ArrayList<>();
        mTitleList = Arrays.asList("密码登录", "快速登录");
        mFragmentList.add(new PwdLoginFragment());
        mFragmentList.add(new MsgLoginFragment());
        mPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mFragmentList.get(position);
            }

            @Override
            public int getCount() {
                return mFragmentList.size();
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return mTitleList.get(position);
            }
        });
        mTabLayout.setupWithViewPager(mPager);
    }

    @Override
    public void onFunctionTxtListener(View view) {
        super.onFunctionTxtListener(view);
        startThenFinish(RegisterActivity.class);
    }
}
